#include<vector>
using namespace std;
class Solution {
public:
    int searchInsert(vector<int>& nums, int target) {
        int min=0,max=nums.size()-1;
        int mid=0;
        while(min<=max)
        {
            mid=min+(max-min)/2;
            if(nums[mid]>target)    max=mid-1;
            else if(nums[mid]<target)   min=mid+1;
            else if(nums[mid]==target)
            return mid;
        }
        return max+1;
    }
};